package cn.project.dao;

import cn.project.model.User;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcDaoSupport;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class UserNamedParaJdbcDaoSupportImple extends NamedParameterJdbcDaoSupport implements UserTempDao {
    public List<User> getAllUser() {
        return null;
    }

    public List <User> getAllUser(User user) {
        return null;
    }

    public User findById(int userid) {
        return null;
    }

    public int save(User user) {
        String sql = "insert into user(username,password) values (:name,:pass)";
        Map map = new HashMap();
        map.put("name",user.getUsername());
        map.put("pass",user.getPassword());
        return getNamedParameterJdbcTemplate().update(sql,map);
    }

    public int update(User user) {
        return 0;
    }

    public int delete(int userid) {
        String sql="delete from user where userid=:userid";
        Map param=new HashMap();
        param.put("userid",userid);
        return getNamedParameterJdbcTemplate().update(sql,param);
    }
}
